﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using IronCow.Rest;

namespace IronCow.UnitTests
{
    [TestFixture]
    public class TestRestClient
    {
        private RestClient Client;

        [SetUp]
        public void SetUp()
        {
            Client = new RestClient("TEST_API_KEY", "TEST_SHARED_SECRET");
        }

        [TearDown]
        public void TearDown()
        {
            Client = null;
        }

        [Test]
        public void TestEscapeRequestParameters()
        {
            Assert.AreEqual("foo", Client.EscapeRequestParameter("foo"));
            
            Assert.AreEqual("%20foo", Client.EscapeRequestParameter(" foo"));
            Assert.AreEqual("!foo", Client.EscapeRequestParameter("!foo"));
            Assert.AreEqual("%22foo%22", Client.EscapeRequestParameter("\"foo\""));
            Assert.AreEqual("%23foo", Client.EscapeRequestParameter("#foo"));
            Assert.AreEqual("%24foo", Client.EscapeRequestParameter("$foo"));
            Assert.AreEqual("%25foo", Client.EscapeRequestParameter("%foo"));
            Assert.AreEqual("%26foo", Client.EscapeRequestParameter("&foo"));
            Assert.AreEqual("'foo", Client.EscapeRequestParameter("'foo"));
            Assert.AreEqual("(foo)", Client.EscapeRequestParameter("(foo)"));
            Assert.AreEqual("*foo", Client.EscapeRequestParameter("*foo"));
            Assert.AreEqual("%2Bfoo", Client.EscapeRequestParameter("+foo"));
            Assert.AreEqual("%2Cfoo", Client.EscapeRequestParameter(",foo"));
            Assert.AreEqual("-foo", Client.EscapeRequestParameter("-foo"));
            Assert.AreEqual(".foo", Client.EscapeRequestParameter(".foo"));
            Assert.AreEqual("%2Ffoo", Client.EscapeRequestParameter("/foo"));

            Assert.AreEqual("%3Ffoo", Client.EscapeRequestParameter("?foo")); 
            Assert.AreEqual("%40foo", Client.EscapeRequestParameter("@foo"));            
        }
    }
}
